Message-based modeling

ABSTRACT

A system and method may generate executable block diagrams in which at least some of the blocks run in accordance with message-based execution semantics. A message may include an input data payload that does not change over time, and the message may persist for only a determined time interval during execution of block diagram. A message-based execution engine may control execution of message-based blocks in which a source block may generate a message at a particular point in time, the message may be sent to one or more destination blocks triggering execution of those blocks, and the message may be destroyed on or after a determined time interval. Other execution domains, such as a time-based or state-based execution domain, may be provided, and the system may implement a hybrid execution model.

CROSS-REFERENCE TO RELATED APPLICATIONS

The present application is a continuation of application Ser. No.13/117,531, filed May 27, 2011 by Hidayet Tunc Simsek et al. forMESSAGE-BASED MODELING, now U.S. Pat. No. 8,640,145, which applicationclaims the benefit of U.S. Provisional Patent Application Ser. No.61/349,401, which was filed on May 28, 2010, by Alan Moore et al., for aMESSAGE BASED TRACES AND VERIFICATION, which applications are herebyincorporated by reference in their entireties.

BRIEF DESCRIPTION OF THE DRAWINGS

The invention description below refers to the accompanying drawings, ofwhich:

FIG. 1 is a schematic illustration of a data processing system;

FIG. 2 is a partial, functional diagram of a high-level modelingenvironment;

FIG. 3 is a schematic illustration of a class hierarchy of message-basedcomponents;

FIG. 4 is a schematic illustration of a class hierarchy of messagetypes;

FIG. 5 is a schematic illustration of a data structure for storing dataelements of a message;

FIGS. 6A-6C are partial views of a flow diagram of exemplary processingthat can be used in accordance with an embodiment of the invention;

FIG. 7 is a smaller scale view indicating the positions of FIGS. 7A and7B to form a whole view;

FIGS. 7A and 7B are partial views of an illustration of a graphicalmodel having executable semantics;

FIG. 8 is; an illustration of a graphical model having executablesemantics;

FIGS. 9A and B are partial views of a flow diagram of exemplaryprocessing that can be used in accordance with an embodiment of theinvention;

FIG. 10 is an illustration of a graphical model having executablesemantics;

FIG. 11 is a flow diagram of exemplary processing that can be used inaccordance with an embodiment of the invention;

FIG. 12 is an illustration of a graphical model having executablesemantics;

FIGS. 13A and B are partial views of a flow diagram of exemplaryprocessing that can be used in accordance with an embodiment of theinvention;

FIG. 14 is an illustration of a graphical model having executablesemantics; and

FIGS. 15A and B are partial views of a flow diagram of exemplaryprocessing that can be used in accordance with an embodiment of theinvention;

DETAILED DESCRIPTION OF ILLUSTRATIVE EMBODIMENTS

Overview

Exemplary embodiments can be used for generating executable blockdiagrams in which at least some of the blocks run in accordance withmessage-based execution semantics. Each message may be an instance of amessage type, and may include a payload comprising one or more dataelements that do not change over time. A message may be generated at aparticular point in time by a source block of the diagram, and maypersist for a determined time interval. Message types may be organizedin one or more class hierarchies. In particular, a plurality of basemessage types may be defined, and for each base message type there maybe one or more derived message types. Through the organization of theclass hierarchy, a message-based block capable of receiving a basemessage type may also be capable of receiving any of the message typesthat are derived from that base message type. A message-based blockcapable of receiving a particular derived type of message, however, maynot be capable of receiving the corresponding base message type.

A message-based modeling system, which may be included within ahigh-level modeling environment, may support message-based functionalityin the block diagram. The system may include a library of pre-definedgraphical blocks configured to generate and send messages, and toreceive and process messages. The library of message-based blocks may beorganized as a class hierarchy. The modeling environment may include agraphical editor that provides a canvas in which a user may construct ablock diagram. Each message-based block may have one or more messageports for sending and receiving messages. In response to the messageports of selected blocks being interconnected, such as throughmessage-based connections extending from source ports to destinationports, the system may establish message-based relationships among theinterconnected blocks.

The system may further include a propagation engine that checks themessage types among the interconnected message-based blocks of thediagram. This process may be performed as part of a compilation of theblock diagram. Specifically, the propagation engine may determinewhether a message type expected by a destination message-block iscompatible with the message type generated by the source message-block.For example, if a destination block expects to receive a message of abase message type as provided in the class hierarchy, and the sourceblock generates either the specified base message type or a message typethat is derived from the specified base message type, then thepropagation engine may determine that the message-based relationship isvalid. If the destination block expects a different base or derivedmessage type than the one generated by the source block, or thedestination block expects a derived message type and the sourcegenerates a base message type, then the propagation engine may determinethat the message-based relationship is not valid, and may issue acompilation error.

The system may also include a message-based execution engine thatcontrols the execution of the message-based blocks in the diagram. Morespecifically, during execution, a source block generates a message at aparticular point in time. The message-based execution engine maymaintain the message for a determined time interval. In addition, theexecution engine may send the message to one or more destination blocks,triggering the execution of the one or more destination blocks, and theexecution engine may control the processing of the message by the one ormore destination blocks.

In an embodiment, the high-level modeling environment may includesystems that support other execution domains, such as a time-basedexecution domain. In addition, the message-based system may cooperatewith such a time-based execution system environment to implement amessage/time-based hybrid execution model. The time-based system mayinclude a library of time-based blocks, and selected time-based blocksmay be added to the block diagram. A time-based block describes adynamic system of equations that defines time-based relationshipsbetween signals and state variables. Signals represent quantities thatchange over time, and may have values at all points in time. Therelationships between signals and state variables may be defined by theset of equations represented by the time-based blocks. Time-based blocksmay include signal ports that may be interconnected with signal-basedconnections. The source of a signal corresponds to the block that writesto the signal during the evaluation of the block's equations, and thedestination of the signal is the block that reads the signal during theevaluation of the destination block's equations.

The time-based execution engine executes the time-based blocks in thediagram by evaluating the relationships between signals and statevariables over time beginning at a start time and continuing to a stoptime. Each evaluation of the relationships may be referred to as a timestep.

As mentioned, the message-based system and the time-based executionengine may cooperate to implement a hybrid environment. In particular,the time-based execution engine may organize the blocks into a sortedorder, which refers to the order in which the blocks' operations ormethods (e.g., execution methods), are invoked. The time-based blocksare then executed according to the sorted order. When a message isgenerated within the block diagram, the execution of the time-basedblocks may be suspended, and the message may be sent to one or moredestination blocks. The one or more destination blocks may then receiveand process the message. When the processing of the message by the oneor more destination blocks is complete, execution of the time-basedblocks according to the sorted order may resume.

The message-based system may also include a verification engine. Theverification engine may support a library containing one or moreverification blocks. Instances of the verification blocks may be addedto the block diagram to evaluate the operation of message-based blocks.The types of verification blocks may include an observer type, a messagesink type, a generator type, and a scenario type. The observer block maybe used to visualize a set of messages, referred to as a trace,generated by one or more selected message-based blocks of the blockdiagram. The set of messages of the trace may be ordered in time betweena start time and an end time by the observer block. The observer blockmay be a floating block within the block diagram, and it may beassociated with a message-based connection. The message sink block maybe directly connected to a message-based block, and may be used tovisualize a trace generated by that message-based block. The generatorblock may be used to represent an external source of messages to theblock diagram. The generator block may be connected to one or moremessage-based blocks as a source, and configured to generate one or moremessages or traces that may then be received and processed by the one ormore message-based blocks to which the generator block is connected. Thescenario block may be used to define valid and invalid traces. It mayalso or alternatively be used to define one or more constraints on oneor more messages or traces. For example, temporal constraints may bedefined on one or more messages, or between two or more messages. Thescenario block may be associated with one or more message-basedconnections in the block diagram whose messages may form a runtime traceto be evaluated. The scenario block may compare the defined valid andinvalid traces, and the one or more constraints, to the runtime traceproduced during execution of the block diagram. The scenario block maybe further configured to take one or more actions if one or more of theruntime traces is not equivalent to the defined valid traces, or theruntime traces are equivalent to the defined invalid traces. Thescenario block may also take a specified action if the one or moreconstraints are not satisfied.

FIG. 1 is a schematic illustration of a computer or data processingsystem 100 for implementing and utilizing an embodiment of theinvention. The computer system 100 includes one or more processingelements, such as a processing element 102, a main memory 104, userinput/output (I/O) device 106, a data storage unit, such as a disk drive108, and a removable medium drive 110 that may all be interconnected bya system bus 112. The computer system 100 may also include acommunication unit, such as a network interface card (NIC) 114. The userI/O device 106 may include a keyboard 116, a pointing device, such as amouse 118, and a display 120. The main memory 104 may store a pluralityof libraries or modules, such as an operating system 122, and one ormore applications running on top of the operating system 122, includinga high-level modeling environment 200.

The removable medium drive 110 may accept and read a computer readablemedium 126, such as a CD, DVD, floppy disk, solid state drive, tape,flash memory or other medium. The removable medium drive 110 may alsowrite to the computer readable medium 126.

Suitable computer systems include personal computers (PCs),workstations, laptops, tablets, palm computers and other portablecomputing devices, etc. Furthermore, exemplary processing elementsinclude single or multi-core Central Processing Units (CPUs), GraphicsProcessing Units (GPUs), Field Programmable Gate Arrays (FPGAs),Application Specific Integrated Circuits (ASICs), etc. Nonetheless,those skilled in the art will understand that the system 100 of FIG. 1is intended for illustrative purposes only, and that the presentinvention may be used with other computer systems, data processingsystems or computational devices. The present invention may also be usedin a networked, e.g., client-server, computer architecture, or a publicand/or private cloud computing arrangement.

Suitable operating systems 122 include the Windows series of operatingsystems from Microsoft Corp. of Redmond, Wash., the Linux operatingsystem, the MAC OS® series of operating systems from Apple Inc. ofCupertino, Calif., and the UNIX® series of operating system, amongothers.

A user or developer, such as an engineer, scientist, programmer, etc.,may utilize the keyboard 116, the mouse 118, and the display 120 tooperate the high-level modeling environment 200, and construct or openone or more models of a system that is being designed. The model, whichmay have executable semantics, may represent a real-world dynamic systemthat is being modeled, simulated, and/or analyzed by the user.

FIG. 2 is partial block diagram of an embodiment of the high-levelmodeling environment 200. The environment 200 may include amessage-based modeling system 202, and one or more additional modelingsystems, such as a time-based modeling system 204, and a state-basedmodeling system 206. The environment 200 also may include a modelexecution engine 208, a model builder 210, and a clock source, such asclock 212. The message-based modeling system 202 may include a pluralityof components or modules. In particular, it may include a propagationengine 214, a message-based execution engine 216, a verification engine218, a report generator 220, and an interface engine 222. The system 202may also include an object constructor 224 that may access one or moreclass packages, such as message-based component class package 226, and amessage-type class package 228.

In an implementation, high-level modeling environment 200 may receiveinputs by a user as the user creates, edits, revises, and/or opens oneor more models, as indicated by arrow 230. The model execution engine208 in cooperation with the modeling systems 202, 204 and 206 mayexecute the model generating one or more results that may be presentedto the user, as indicated by arrow 232. A model may include a pluralityof portions each operating according to a different execution domains.For example, a first portion may operate according to message-basedsemantics, a second portion may operate according to time-basedsemantics, and a third portion may operate according to state-basedsemantics.

In an embodiment, a graphical model may be executable such that themodel receives one or more inputs, processes those inputs, and producesone or more outputs.

In an embodiment, a suitable high-level modeling environment includesthe MATLAB® technical computing environment from The MathWorks, Inc. ofNatick, Mass. The high-level modeling environment may thus operate at alevel that is even higher than other well-known programming languages,such as the C, C++, and C# programming languages. A suitable time-basedmodeling system includes the SIMULINK® environment from The MathWorks,Inc. A suitable state-based modeling system includes the Stateflowcharting tool from The MathWorks, Inc.

It should be understood that other modeling tools in addition to or inplace of the time-based modeling system 204 and/or the state-basedmodeling system 206 may be used in the environment 200. Other suchmodeling tools include dataflow systems, such as the LabVIEW programmingsystem from National Instruments Corp. of Austin, Tex., and the VisualEngineering Environment (VEE) from Agilent Technologies, Inc. of SantaClara, Calif., physical modeling systems, such as The Simscape productfrom The MathWorks, Inc., Unified Modeling Language (UML) systems, andSystems Modeling Language (SysML) systems, among others. In addition, alower level programming language, such as the C, C++, and C# programminglanguages, among others, may also be used to create one or more modelsor model portions.

The propagation engine 214, message-based execution engine 216,verification engine 218, report generator 220, interface engine 222,message-based object constructor 224, and class packages 226, 228 mayeach comprise registers and combinational logic configured and arrangedto produce sequential logic circuits. In an embodiment, the propagationengine 214, message-based execution engine 216, verification engine 218,report generator 220, interface engine 222, message-based objectconstructor 224, and class packages 226, 228 may be implemented throughone or more software modules or libraries containing programinstructions pertaining to the techniques described herein. The softwaremodules may be stored on main memory 104 and/or computer readable media,such as computer readable medium 126, and executable by one or moreprocessing elements, such as processing element 102. Other computerreadable media may also be used to store and execute these programinstructions. In alternative embodiments, various combinations ofsoftware and hardware, including firmware, may be utilized to implementthe present invention.

In an embodiment, the message-based components of a graphical model aswell as the messages generated during execution of the model may beobjects, and these objects may be defined by creating “classes” whichare not objects themselves, but which act as templates that instruct theconstructor 224 how to construct an actual component and message object.A class may, for example, specify the number and type of data variablesand the steps involved in the functions which manipulate the data. Theobject constructor 224 may use the corresponding class definition andadditional information, such as arguments provided during objectcreation, to construct the object. Likewise, objects may be destroyed bya special function called a “destructor”. Objects may be used bymanipulating their data and invoking their functions.

FIG. 3 is a schematic illustration of an exemplary class hierarchy 300of message-based components. Instances of objects defined in the classhierarchy 300 may be constructed for use in a graphical model. The classhierarchy 300 may include one or more base classes, such as a Generatorclass 302, a Sink class 304, a Gateway class 306, and a Client/Serverclass 308. In addition, one or more of the base classes may include oneor more derived classes, which may also be referred to as sub-classes.For example, the Generator base class 302 may include a Message Buildersubclass 310 and a Period Message Generator subclass 312. The Sink baseclass may include a Message Receive subclass 314 and a Message Viewersubclass 316. The Gateway base class 306 may include a Message to Signalsubclass 318 and a Message to Event subclass 320. The Client/Server baseclass 308 may include a Client subclass 322 and a Server subclass 324.

It should be understood that other, possibly more complex, classhierarchies may be provided. For example, additional base classes may beprovided, and one or more of the subclasses may include subclasses ofits own, and so on.

FIG. 4 is a schematic illustration of an exemplary class hierarchy 400of message types, such as error messages. The hierarchy 400 may includean Error base class 402. The Error base class 402 may have one stringproperty named “message”. The Error base class 402 may include aplurality of derived classes, such as a Fatal Error subclass 404, aWarning subclass 406, and a Recoverable Error subclass 408, which maydefine other class specific properties. The Fatal Error subclass 404 mayhave one string property named “errorcode”. The Warning subclass 406 mayhave one string property named “warningcode”. The Recoverable Errorsubclass 408 may have one string called “recoverycode”. Furthermore, theFatal Error subclass 404 may have a plurality of derived classes, suchas an Engine Stalled subclass 410, a Controller Not Responding subclass412, a Temperature Error subclass 414, and a Pressure Error subclass416. The Temperature Error subclass 414 may have one floating pointproperty called “temperature”, and the Pressure Error subclass 416 mayhave one floating point property called “pressure”. The RecoverableError subclass 408 may have one derived class, such as a One Sensor NotWorking subclass 418.

While the message types are referred to as classes, in an embodiment,they do not have any methods. Instead, the specialization of the messageclasses may add new properties, i.e., data members, only.

In an embodiment, an instance of a message object may include one ormore data elements. FIG. 5 is a schematic illustration of a datastructure 500 representing the data elements of an instance of a messageobject. The data structure 500 may be organized into a plurality offields and sub-fields each storing particular information. For example,the data structure 500 may include a message type field 502, a messageidentifier (ID) field 504, a valid flag 506, a time to live (TTL) field508, and a payload field 510. The message type field 502 may storeinformation that indicates the particular type of message, the messageID field 504 may store an identifier that uniquely identifies themessage, the valid flag 506 may indicate whether the message is valid orinvalid, the TTL field 508 may store information indicating how long themessage should be maintained, and the payload field may storeinformation associated with the message that was generated by themessage source and that may be used by one or more message destinations.

It should be understood that the data structure may include additionalor fewer fields. In addition, the payload field 510 may be organizedinto a plurality of sub-fields.

In another embodiment, message-based components and/or messages may beinstances generated from types, instead of being objects generated fromclasses. Those skilled in the art will understand that otherimplementations of message-based components and/or messages may beutilized.

FIGS. 6A-C are partial views of a flow diagram illustrating exemplaryprocessing for practicing an embodiment of the invention. The high-levelmodeling environment 200 may receive inputs from a user constructing oropening a model, as indicated at block 602. Environment 200 may supportthe creation of models through graphical, textual, or a combination ofgraphical and textual inputs. The user may operate and interact withenvironment 200 through the user I/O 106, such as the keyboard 116,mouse 118, and display 120. For example, the environment 200 and/or oneor more of the message-based modeling system 202, the time-basedmodeling system 204, and the state-based modeling system 206 may presentone or more model editor windows on the display 120. The model editormay include a plurality of graphical elements, such as a menu bar, atool bar, and a canvas. In addition, the message-based modeling system202, the time-based modeling system 204, and the state-based modelingsystem 206 may each provide a library browser window or palette thatpresents a plurality of component types. The user may select one or morecomponent types from the library browsers or palettes, and placerespective ones of those components on the canvas. The user may thenconnect the components, e.g., with connections, that may appear as linesor arrows on the canvas, thereby establishing message-based,mathematical time-based, state-based, dataflow, or other relationshipsamong the components placed onto the canvas.

The environment 200 may also support the creation of a modelprogrammatically.

In an embodiment, a user may select one or more types of message-basedcomponents from the library browser. In response, the constructor 216may access the component class package 226, and create an objectinstance of the selected type, as indicated at block 604. The objectinstance may be stored in memory, such as main memory 104, and an icon,such as a block, may be added to the canvas, as indicated at block 606.

The user may configure one or more of the components of the model togenerate and/or receive a message, as indicated at block 608. Forexample, a user may open a properties or other page associated with aselected message-based component that has been added to the canvas. Theproperty page may include fields or other data entry elements forreceiving information, for example, from the user, specifying a messagetype that the component is to receive. In response, the objectconstructor 224, or another module, such as the model builder 210, mayadd an input port to the block as presented on the canvas. Similarly,the property page, or another property page, may include fields and dataentry elements for receiving information that specifies a message typethat a selected component is to send. In response, an output port may beadded to the block as presented on the canvas. In this way, a user mayadd a plurality of blocks representing message-based components to thecanvas, and provide these blocks with input and output ports forreceiving and sending messages.

The user may define message-based relationships among the message-basedcomponents of the model as well as the other components, as indicated atblock 610. For example, the user may define a message-based relationshipgraphically by drawing a message-based connection between the input andoutput ports of message-based blocks. More specifically, the user mayconfigure a given message-based component to receive a particularmessage by drawing a connection from the source of the message, such asthe output port of another message-based component, to the respectiveinput port of the given message-based component. Likewise, the user mayconfigure a selected message-based component to send a message bydrawing a connection from the respective output port of the selectedmessage-based component to the destination of the message. In responseto the definition of message-based relationships, e.g., by the user, themessage-based execution engine 216 may add the destination component toa list of listeners for the respective message, as indicated at block612. Specifically, the execution engine 216 may create a list oflisteners for each message for which a message-based relationship hasbeen defined in the model. If a message-based relationship is removed,for example, by the user deleting a message-based connection between twomessage-based blocks, the execution engine 216 may remove thedestination component from the list of listeners for that message.

In an embodiment, model components operating in domains other than themessage-based execution domain, may be configured to send or receivemessages. For example, a user may draw a message-based connectionbetween a message-based block and a block operating in another domain,such as the time-based domain, the state-based domain, the dataflowdomain, etc. Likewise, a user may draw a message-based connection from ablock operating in another domain to a message-based block.

FIGS. 7A and 7B are partial views of a schematic illustration of anexemplary graphical model 700. FIG. 7 is a smaller scale view indicatingthe positions of FIGS. 7A and 7B to form a whole view. The model 700 maybe constructed and/or opened by a user. The model 700 may include afirst time-based portion 702, a second time-based portion 704, astate-based portion 706, and a message-based portion 708. Each portionmay include a plurality of components, such as blocks or subsystems.Specifically, the first time-based portion 702 may include a Constantblock 710 and a Gain block 712. The second time-based portion 704 mayinclude an If block 714, a first Subsystem 716, a second Subsystem 718,a Mux block 720, a Gain block 722, and an Outport block 724. Thestate-based portion 706 may include an Idle state 726 and a Waitingstate 728. The message-based portion 708 may include a True block 730,Message Generator block 732, a Message Buffer block 734, and a MessageReceive block 736.

The Message Generator block 732 may be configured to have two inputports 740 a, 740 b, each associated with a respective type of messagethat the Message Generator block 732 is interested in receiving. TheMessage Generator block 732 also may be configured to have one outputport 742 that is associated with a message type that the MessageGenerator block may send. The Message Buffer block 734 may be configuredwith an input port 744 and an output port 746, each associated with arespective message type. The Message Receive block 736 may be configuredwith an input port 748 and two output ports 750 a, 750 b, eachassociated with a respective message type. In addition, the state-basedportion 706 may be configured with a first input port 752 a that isassociated with a type of message, and a second input port 752 b that isassociated with a signal. The state-based portion 706 may be furtherconfigured with a first output port 754 a that is associated with a typeof message, and a second output port 754 b that is associated with asignal.

In an embodiment, the data type of a message payload may specify thetype of message.

Message-based relationships may be established among the time-basedportions 702, 704, the state-based portion 706, and the message-basedportion 708. For example, a user may connect various input and outputblocks of the model 700 with message-based connections. In response,constructor 224 may create message object instances, and the executionengine 214 may establish message-based relationships among therespective portions or components of the model 700.

In an embodiment, before execution of the model 700, the propagationengine 214 may analyze the construction and configuration of the model700 to determine whether, during execution of the model 700, thoseblocks that are configured to receive messages will receive the intendedmessages, as indicated at block 614. In particular, the message-basedexecution engine 216 and the model execution engine 208 may build anin-memory representation of the model 700, such as an intermediaterepresentation (IR). The IR may include a plurality of nodes, that mayrepresent the blocks of the model 700, and edges that representconnections within the model. The IR may also be annotated withadditional information, such as the types of messages that destinationblocks are configured to receive, the types of messages that sourceblocks are configured to send, etc. The IR may be created as part of acompilation stage that marks the start of model execution. Thiscompilation stage may include preparing data structures and evaluatingparameters, configuring and propagating block characteristics,determining block connectivity, and performing block reduction andinsertion. In addition, one or more optimization techniques may beapplied to the IR. After the application of an optimization technique,an additional IR may be generated. The propagation engine 214 mayanalyze one or more of these IRs.

The propagation engine 214 may evaluate this IR examining, for example,those elements of the IR that represent the input ports of message-basedand other blocks. The propagation engine 214 may determine the type ofmessage that the given message-block expects to receive on a subjectinput port. The propagation engine 214 also may identify the upstreamblock that is connected to the subject input port of the givenmessage-based block. The propagation engine 214 may determine the typeof message issued by this upstream block. In addition, the engine 214may determine whether the type of message defined for the output port ofthe source component complies with the type of message defined for theinput port of the destination component. If a mismatch is identified byengine 214, it may be reported. For example, an error message or errorreport may be generated and presented, for example on the display 120for review by the user.

The model 700 may be simulated, e.g., executed or run. For example, themodel editor window may include a Run command button that may beselected by the user, e.g., with the mouse 118. Alternatively, the usermay enter a text-based run command, for example, in a Command LineInterface (CLI), or the model may be run programmatically.

In an embodiment, the model execution engine 208 interfaces with thetime-based system 204, the state-based system 206, and the message-basedsystem 202 to execute the entire model 700, as indicated at block 616.

In an embodiment, the time-based modeling system 204 may create a sortedorder of the time-based components of the model 700, as indicated atblock 618. The sorted order may refer to the order in which to invokeblock methods, during execution of the model 700. Exemplary blockmethods for time-based components may include an output method thatcomputes the output signals of the block based on its input signals andits state, an update method that computes the block's states, and aderivatives method that computes the derivatives of the block'scontinuous states. Time-based components that are configured to executetogether may be identified as a group in the sorted order. For example,a time-based subsystem may include a plurality of time-based blocks, andthe subsystem may be configured to run as an atomic subsystem. In thiscase, all of the time-based blocks of the atomic subsystem executeatomically as a group. The time-based modeling system 204 may alsodefine a simulation start time, a simulation end time, and a pluralityof time steps between the start and end times. The size of the timesteps may depend on the particular solver being used to execute themodel.

Input and output signals may be represented graphically in the model orblock diagram by arrow elements extending between time-based blocks.Input and output signals represent quantities, for example, input andoutput data that change over time during the execution of the model, andthe quantities represented by the signals may be defined, and thus havevalues, for all points in time between a model's start time and its stoptime. Execution of a model may also be referred to as simulation of themodel.

In an embodiment, one or more initialization steps may be performedbefore execution of the model begins. For example, one or morestate-based portions of the model may execute one or more defaulttransitions, as indicated at block 620. Initialization steps formessage-based portions of the model may involve typical operations, suchas dequeuing a waiting message.

For each time step of the simulation, which may begin with thesimulation start time, execution of model may proceed as follows. Thetime-based modeling system 204 in cooperation with the model executionengine 208 may begin executing the time-based components of the modelaccording to the sorted order, as indicated at block 622. If an eventthat is a triggering event for a state-based portion of the modeloccurs, the execution of the time-based components may be suspended, asindicated at block 624. The triggered state-based portion may beexecuted as an atomic unit, for example, by the state-based modelingsystem 206 in cooperation with the model execution engine 208, asindicated at block 626. Upon completing the execution of the state-basedportion, the execution of the time-based components may resume from thepoint in the sorted-order at which execution had been suspended, asindicated at block 628. For example, the model execution engine 208 mayrecord where in the sorted order the execution was suspended to executethe state-based portion.

In an embodiment, an input triggering event may occur outside of astate-based portion, for example, by a time-based or other component,but may be visible within the state-based portion. Exemplary inputtrigger events may include an edge-triggered input event and a functioncall, for example, from a time-based component. An edge-triggered inputevent may be configured to operate on a rising edge, a falling edge, oreither a rising or falling edge. To operate as an input edge-triggeredinput event, a signal from a time-based component may need to crosszero, such as a changing from −1 to 1. In contrast, a function-callinput event may consist of an instantaneous flow of control from acaller subsystem to a callee subsystem. A triggering event for astate-based portion, whether it is an edge, function call or othertrigger, may not provide any input data to the state-based portion,which the state-based portion might otherwise use for processing, forexample to generate output data. Instead, the triggering event mayoperate as a control signal that triggers execution of thestate-portion, and the state-based portion may operate upon input datathat is internal to the state-based portion, or that is received inother ways besides a triggering event.

If the triggering event for the state-based portion occurs during theexecution of a group of time-based components that are configured toexecute atomically, then the execution of the entire group of time-basedcomponents may be completed. Further execution of time-based componentsmay then be suspended, and the execution of the triggered state-basedsystem performed.

If a message is generated and sent, for example, during the execution oftime-based components according to the sorted order, then the executionof time-based components may be suspended, as indicated at block 630.The message-based execution engine 216 may examine the list of listenersfor the respective message. The execution engine 216 may send themessage to the components on the list of listeners, as indicated atblock 632. If the destination component is triggered by the receipt ofthe message, the execution engine 214 may execute the destinationcomponent, as indicated at block 634. The message-based execution engine214 may also start a timer associated with the generation of a message,and may track the age of the message, as indicated at block 636. Forexample, the engine 212 may use the clock 212 to operate one or moretimers. When the age of the message reaches its maximum age, which maybe indicated in message's TTL field 508, the message may be destroyed bythe message-based execution engine 216, as indicated at block 638. Eachmessage may thus persist for only a defined time period during theexecution of a model.

Upon completing the execution of the components triggered by themessage, the execution of the time-based components may resume from thepoint in the sorted-order at which execution had been suspended, asindicated at block 640.

It should be understood that the model execution flow described inconnection with one or more of steps 622 to 640 may be nested. Forexample, the execution of a state-based portion may generate a messagetriggering the execution of a message-based portion, which may triggerthe execution of a state-based portion, and so on.

It should be understood that a message may be sent to a message-basedcomponent, a state-based component, a time-based component, or someother component. In addition, the message-based component, thestate-based component, and the time-based component may execute inresponse to the received message.

The life-time of a message may depend on the semantics of the messageprocessing environment. A message implemented using function-callsemantics may get created and consumed in the same time-step, thusresulting in a lifetime of a single time-step. In the presence ofqueuing semantics, messages can be produced in one time-step but wait ina message queue for a number of time-steps before they are consumed. Inaddition, the consumer can choose to process a message without consumingthe message, thus resulting in messages with potentially infinitelifetime.

In an embodiment, instead of sending a message to a destinationcomponent, the message-based execution engine 216 may notify adestination component that a message has been created. In response, thedestination component may retrieve the message. If the destinationcomponent fails to retrieve the message before its maximum age isreached, the message may be destroyed before ever being retrieved.

In an embodiment, a message-based component may be configured, uponsending a message, to expect a reply to its message. Such a componentmay be configured to execute in a synchronous or asynchronous manner.For example, the component may be configured to execute synchronously inwhich case the component, after sending its message, waits to receivethe reply before continuing with its execution. Alternatively, thecomponent may be configured to execute asynchronously in which case thecomponent, after sending its message, proceeds with its executionwithout waiting for the reply.

In an embodiment, a state-based portion of the model may be configuredto execute during a time step even though no triggering event for thatstate-based portion occurred during the time step. More specifically, astate-based portion may register for time-based triggering. If the modelincludes a state-based portion that is registered for time-basedtriggering, and the state-based portion has not already executed duringthe current time step, then the model execution engine 208 may executethe state-based portion, as indicated at block 642.

At this point, execution during the current time step may be complete.If the current time step does not equal the simulation end time, thecurrent time step may be incremented and the execution process may berepeated. This process, for example steps 622 to 640, may be repeatedfor each time step between the simulation start time and the simulationend time.

Referring to model 700 (FIG. 7), execution at each time step may proceedas follows. Time-based Constant and Gain blocks 710 and 712 may executefirst as they may be the first blocks in the sorted order. The signaloutput of Gain block 712 may be a trigger event for the state-basedportion 706. Accordingly, after Gain block 712 executes, execution ofother time-based components may be suspended, and the state-basedportion 706 may be executed. The Message Receiver block 736 isconfigured to listen for a message from the state-based portion 706 oninput port 448. If the execution of the state-based portion 706 resultsin the generation and sending of this message, the message is receivedby Message Receiver block 736 causing it to be executed. Next, theblocks of the second time-based portion 704 execute following thecompletion of execution of the Message Receiver block 736, assuming itexecutes. Execution of the second time-based portion 704 results in thegenerating and sending of a message that is received by the MessageGenerator block 732. If the second time-based portion 704 is configuredas an atomic subsystem, then all of its blocks, including Gain block 722and Outport block 724 will execute before the Message Generator block732 executes. On the other hand, if the second time-based portion 704 isnot configured as an atomic subsystem, then the Message Generator block732 may execute before execution of the Gain block 722 and Outport block724.

If the execution of the Message Generator block 732 results in thegeneration and sending of a message, then the Message Buffer block 734may execute, as it is triggered by such a message. If the execution ofthe Message Buffer block 734 results in the generation and sending of amessage, then the state-based portion 706 may execute again.

At this point, execution of the current time step may be complete. Themodel execution engine 208 may increment the time step and execute themodel 700 again, unless the simulation end time has been reached.

Verification of a Message-Based Portion of a Model

In a further aspect of the invention, verification or other testing maybe performed on one or more message-based portions of a model. In anembodiment, one or more verification components may be provided toverify a message-based portion of a model.

Message Observer

In an embodiment, the verification engine 218 may create a firstverification component, which may be referred to as an observer, forverifying one or more messages in a model. The observer may beassociated with a particular message-based connection in a model, andmay present information concerning one or more of the messages thattravel across that connection during execution of the model. In anembodiment, the observer component operates, at least in part, as aviewer to present information concerning all of the messages that travelacross the selected connection during execution of the model. Theobserver component may provide a message-based view that includes theset of message participants, such as the sources and destinations, thetypes of messages generated and sent, and the payloads of those message.This collection of information may be referred to as an interaction.

FIG. 8 is a schematic illustration of a graphical model 800 havingexecutable semantics. The model 800 includes a plurality ofinterconnected components. Specifically, the model 800 has two Inports802, 804, a Sensors component 806, a Bus component 808, a Controllercomponent 810, an Actuators component 812, and an Outport 814. TheInports 802, 804 and the Outport 814 may be time-based components, whilethe Sensors, Bus, Controller, and Actuators components 806, 808, 810,812 may be message-based components. In addition, the Bus component 808and the Controller component 810 may be connected by a message-basedconnection 816. Exemplary embodiments may allow one or more messages tobe sent by the Bus component 808 and received by the Controllercomponent 810 during execution of the model 800 when the Bus component808 is connected to the Controller component 810 using a message-basedconnection. In addition, the Controller component 810 may generate andsend one or more reply messages to the Bus component 808.

Suppose a user is interested in examining and verifying the actualmessages exchanged between the Bus component 808 and the Controllercomponent 810 across the message-based connection 816 during executionof the model 800. In this case, the user may access an Observercomponent, such as Observer component or block 820.

FIGS. 9A and B are partial views of a flow diagram illustratingexemplary processing in accordance with an embodiment of the invention.

The verification engine 218 may receive a request for an Observer block,as indicated at block 902. The verification engine 218 may also receivea designation of one or more message-based connections to which therequested Observer block is to be associated, as indicated at block 904.In response to the request, the verification engine 218 may cooperatewith the constructor 224 to create an Observer component, such as anobject instance. In addition, the model builder 210 may present acorresponding Observer block, such as block 820, in the graphical model800, as indicated at block 906. A user may issue a request for anObserver block either textually, e.g., by entering a command in aCommand Line Interface (CLI), or graphically, e.g., by selecting anObserver block from a library browser. In an embodiment, a user mayselect a message-based connection of interest, for example, connection816, such as with the mouse 118. In response, the verification engine218 may present one or more selectable commands in a drop-down list,including an ‘Insert Observer Block’ command. The user may select the‘Insert Observer Block’ command, thereby causing an Observer componentto be created that is associated with the selected message-basedconnection.

In an embodiment, the Observer block 820 may include a plurality ofGraphical User Interface (GUI) elements. Specifically, the Observerblock 820 may include corresponding icons for the two or moremessage-based participants, e.g., the components connected by themessage-based connection to which the Observer block is associated.Here, the Observer block 820 may include a first box element 822representing the Bus component 808, and a second box element 824representing the Controller component 810. The Observer block 820 mayalso include a line element, such as line elements 826, 828 extendingfrom each box element 822, 824. Information concerning messagesexchanged between the Bus component 808 and the Controller component 810across message-based connector 816 may be presented between the lineelements 826, 828 of the Observer block 820.

After issuing a request for an Observer block and associating it with amessage-based connection of interest, the model may be executed, asindicated at block 908. As part of the execution of the model 800, theBus component 808 may generate and send one or more messages to theController component 810, and the Controller component 810 may respondwith one or more reply messages. Information concerning this exchange ofmessages may be presented by the Observer block 820.

Specifically, the verification engine 218 may monitor the sending andreceiving of messages across the selected message-based connector 86, asindicated at block 910. For example, the verification engine 218 mayinterface with the message-based execution engine 216. In addition, aseach such message is generated and sent, the verification engine 218 mayadd an entry to the Observer block for that message, as indicated atblock 912. The verification engine 218 may also include within eachentry one or more information elements concerning the respectivemessage, as indicated at block 914. For example, the verification engine218 may add an arrow element to the Observer block 820 for each actualmessage. An arrow pointing from line element 828, which extends from boxelement 822, to line element 830, which extends from box element 824,may represent a message sent from the Bus component 808 to theController component 810. An arrow pointing from line element 830 toline element 828 may represent a reply message sent from the Controllercomponent 810 to the Bus component 808. The verification engine 218 mayalso include a data element at each entry that indicates the type ofmessage sent, and that includes information from the message's payload.The entire payload or a portion thereof may be included in the entry'sdata element.

In addition, the verification engine 218 may include one or more timeelements in the entry for a given message. The one or more time elementsmay contain information relating to the timing characteristics of themessage. In particular, a message may be sent by a source component at aparticular time, which may be denoted as the TimeSent, T_(S), and may bereceived by a destination component at a particular time, which may bedenoted as TimeReceived, T_(R). One or more of these timingcharacteristics, such as T_(S) and/or T_(R), may be included in theentry of the Observer block 820 by the verification engine 218.

The timing characteristics of a message may be determined by theverification engine 218 in cooperation with the message-based executionengine 216. For example, system 202 may receive a clock signal fromsystem clock 212, and the message-based execution engine 216 may usethis clock signal to identify one or more timing characteristics ofmessages.

As illustrated in the Observer block 820, four messages were generatedand sent across the message-based connection 816 during execution of themodel 800, as indicated by arrow elements 830-833. All four messageswere sent by the Bus component 808 to the Controller component 810 asindicated by the arrow elements 830-833. Furthermore, each of the fourmessages may be ‘Altitude’ type messages, and may carry the followingpayloads: ‘10,000’, ‘20,000’, ‘30,000, and ‘40,000’. In addition, thefour messages were received by the Controller component 810 at thefollowing times: 12 s, 18 s, 20 s, and 21.4 s, as indicated by timingelements 834-837 of the Observer block 820.

The verification engine 218 may also receive a request for a report ofthe messaging information presented by the Observer block 820, asindicated at block 916 (FIG. 9B). For example, a user may request such areport. The verification engine 218 may provide the information to thereport generator 220, as indicated at block 918, and the reportgenerator 220 may create a report, as indicated at block 920. The reportgenerator 220 may provide the report to an output device, such as thedisplay 120, a printer, etc., as indicated at block 922. The reportgenerator 220 may also or alternatively save the report in memory, asindicated at block 924.

The Observer block 820 may be docked, that is fixed, to the model 800.The Observer block 820 also may be visually associated with themessage-based connection 816 through a line element (not shown)connecting the Observer block 820 to the connection 816. Alternatively,the Observer block 820 may be a floating block. A floating block is notlocked to any particular location in the model 800, but may be movedaround the canvas, for example, by the user. In this case, an icon, suchas a glasses element 840, may be placed near the connection 816 toindicate that an Observer block is associated with this message-basedconnection.

Message Source Block

The verification engine 218 may create a second verification blockreferred to as a Message Source block. The Message Source block may beconnected to a destination component of a model through one or moremessage-based connections. The Message Source block may be used todefine one or more messages, and these messages may be sent from theMessage Source block to the destination block during execution of themodel.

FIG. 10 is a schematic illustration of a graphical model 1000 havingexecutable semantics. The model 1000 includes a Controller component1002, an Actuators component 1004, and an Outport component 1006. TheController and Actuators components 1002, 1004 may be message-basedblocks, and the Outport component 1006 may be a time-based block.Suppose the model 1000 is intended to be used in a larger model in whichthe Controller component 1002 will receive one or more messages. Supposefurther, that a user wants to verify the operation of the model 1000when the Controller component 1002 receives these one or more messages.The user may add a Message Source component or block to the model 1000,such as Message Source block 1008, and may connect it to the Controllercomponent 1002 using a message-based connection 1010. A Generator block1012 that is associated with the Message Source block 1008 also may becreated by the verification engine 218. In an embodiment, the MessageSource block 1008 and the Generator block 1012 may be combined into asingle block, which may be referred to as a Message Source block. AMessage Source block may be used to simulate the one or more messagesthat the Controller component 1002 would have received as part of thelarger model. In this way, a user may test the operation of theController component 1002 and/or the model 1000.

FIG. 11 is a flow diagram of exemplary processing that can be used inaccordance with an embodiment of the invention.

The verification engine 218 may receive a request for a Message Sourceblock, as indicated at block 1102. In response, the constructor 224 maycreate an instance of a Message Source block, and the model builder 210may present a Message Source block and a Generator block on the canvas,as indicated at block 1104. The verification engine 218 may also receivea designation of one or more destination blocks that are to receivemessages generated and sent by the Message Source block, as indicated atblock 1106. The verification engine 218 may provide one or more GUIelements within the Generator block 1012 for receiving information thatdefines one or more messages to be generated and sent by the MessageSource block 1008. For example, the verification engine 218 may includea system boundary box element 1014, and a Controller box element 1016 inthe Generator block 1012. The verification engine 218 also may include afirst line element 1018 extending from the system boundary box element1014, and a second line element 1020 extending from the Controller boxelement 1016. Information defining one more messages may be entered, forexample by the user, between the first and second line elements 1018,1020. For example, a user may draw an arrow element, e.g., using themouse 118, from first line element 1018 to the second line element 1020,thereby defining a first message to be generated and sent to theController component 1002 during execution of the model 1000. The usermay enter information specifying the type of message, its lifetime, andits payload. The user may also specify one or more timingcharacteristics, such as when each message is to be sent. For example,the user may indicate that a respective message is to be generated andsent during each time step of the model's execution. Alternatively, theuser may specify that a respective message is to be sent once during theexecution of a model, such as during a designated particular time step.As the user enters information defining one or more messages in theMessage Source block, this information may be received by theverification engine 218, as indicated at block 1108.

For example, a first arrow element 1022 may be added to define a firstmessage of type ‘Altitude’ having a payload of ‘10,000’, and a messagesend time of 12 s. A second arrow element 1023 may be added to define asecond message of type ‘Altitude’ having a payload of ‘20,000’, and amessage send time of 18 s. A third arrow element 1024 may be added todefine a third message of type ‘Altitude’ having a payload of ‘30,000’,and a message send time of 20 s. A fourth arrow element 1025 may beadded to define a fourth message of type ‘Altitude’ having a payload of‘40,000’, and a message send time of 21.4 s. A fifth arrow element 1026may be added to define a fifth message of type ‘Anomaly’ with a messagesend time of 22 s.

Once the desired messages have been defined, the model 1000 may beexecuted, as indicated at block 1110. During execution of the model1000, the verification engine 218 may cooperate with the executionengine 216 to cause the one or more messages defined in the Generatorblock 1012 to be generated and sent by the Message Source block 1008 atthe specified times, where the messages are of the specified type andcarry the specified payloads, as indicated at block 1112. One or more ofthese messages may trigger execution of the Controller component 1002,as indicated at block 1114.

Message generation time may be specified in absolute terms, for example,from the start of the simulation of a model. In addition, messagegeneration time may be specified relative to a preceding message.

Message Sink Block

The verification engine 218 may create a third verification blockreferred to as a Message Sink block. The Message Sink block may beconnected to a source component of a model through one or more messagebased connections, and may present information concerning one or moremessages generated by the source component during execution of themodel. In an embodiment, the Message Sink block operates as a viewer topresent information concerning all of the messages generated by thesource component during execution of the model.

FIG. 12 is a schematic illustration of a graphical model 1200 havingexecutable semantics. The model 1200 includes a plurality ofinterconnected components. Specifically, the model 1200 has two Inports1202, 1204, a Sensors component 1206, and a Bus component 1208. TheInports 1202, 1204 may be time-based blocks, and the Sensors and Buscomponents 1206, 1208 may be message-based components. Suppose the model1200 is intended to form part of a larger model, and that the Buscomponent 1208 is intended to generate and send one or more messages toone or more components of this larger model. Suppose further that a userwants to verify the messages being generated and sent by the Buscomponent 1208. The user may add a Message Sink block, such as MessageSink block 1210, to the model 1200. The user may also connect theMessage Sink block 1210 to the Bus component 1208 with a message-basedconnection 1212. A Message Viewer block 1212 that is associated with theMessage Sink block 1210 also may be created by the verification engine218. In an embodiment, the Message Sink block 1210 and the MessageViewer block 1212 may be combined into a single block, which may bereferred to as a Message Sink block. The Message Viewer block 1212 maybe an instance of an Observer block.

FIGS. 13A and 13B are partial views of a flow diagram illustratingexemplary processing that can be used in accordance with an embodimentof the invention.

The verification engine 218 may receive a request for a Message Sinkblock, as indicated at block 1302. The verification engine 218 may alsoreceive a designation of one or more message sources for the MessageSink block, as indicated at block 1304. In response to the request, theconstructor 224 may create a Message Sink object instance, and the modelbuilder 210 may present a corresponding Message Source block and aMessage Viewer block in the graphical model 1200, as indicated at block1306. A user may issue a request for a Message Source block eithertextually, e.g., by entering a command in a Command Line Interface(CLI), or graphically, e.g., by selecting it from a library browser.

In an embodiment, the Message Viewer block 1212 may include a pluralityof GUI elements. Specifically, the Message Viewer block 1212 may includea first box element 1214 for the message source, i.e., the Bus component1208, and a second box element 1216 for a system boundary. The MessageViewer block 1212 may also include a first line element 1218 extendingfrom the first box element 1214, and a second line element 1220extending from the second box element 1216. Information concerningmessages generated and sent by the Bus component 1208 may be presentedbetween the first and second lines 1218, 1220 of the Message Viewerblock 1212.

After requesting the Message Sink block 1210 and connecting it to thesource of interest, the model 1200 may be executed, as indicated atblock 1308. As part of the execution of the model 1200, the Buscomponent 1208 may generate and send one or more messages.

The verification engine 218 may monitor the generating and sending ofmessages by the Bus component 1208, as indicated at block 1310. Inaddition, as each such message is generated and sent, the verificationengine 218 may add an entry to the Message Viewer block 1212 for thatmessage, as indicated at block 1312. The verification engine 218 mayalso include one or more information elements for each entry added tothe Message Viewer block 1212, as indicated at block 1314. Theseinformation elements may provide additional information on the messages.Specifically, each entry may include an arrow element extending from thefirst line element 1218 to the second line element 1220, therebyindicating that the message was sent by the Bus component 1208. Eachentry may also identify the type of message, and may include informationfrom the message's payload. The entire payload or a portion thereof maybe included in the respective entry in the Message Viewer block 1212.One or more entries may also include one or more time elements thatprovide information concerning the timing characteristics of therespective message, such as the time the message was sent, T_(S), and/orthe time the message was received, T_(R).

For example, a first arrow element 1222 may be presented in the MessageViewer block 1212 during execution of the model 1200 by the verificationengine 218 indicating that a first message of type ‘Altitude’ having apayload of ‘10,000’, was sent by the Bus component 1208 at time 12 s. Asecond arrow element 1223 may be presented indicating that a secondmessage of type ‘Altitude’ having a payload of ‘20,000’, was sent attime 18 s. A third arrow element 1224 may be added indicating that athird message of type ‘Altitude’ having a payload of ‘30,000’, was sentat time of 20 s. A fourth arrow element 1225 may be presented indicatingthat a fourth message of type ‘Altitude’ having a payload of ‘40,000’,was sent at time of 21.4 s.

The verification engine 218 may also receive a request for a report ofthe message information captured by the Message Sink block 1210 and/orpresented in the Message Viewer block 1212, as indicated at block 1316(FIG. 13B). For example, a user may request such a report. Theverification engine 218 may pass the information to the report generator220, as indicated at block 1318, and the report generator 220 may createa report, as indicated at block 1320. The report generator 220 mayprovide the report to an output device, such as the display 120, aprinter, etc., as indicated at block 1322. The report generator 220 mayalso or alternatively save the report in memory, as indicated at block1324.

Message Scenario Block

The verification engine 218 may create a fourth verification blockreferred to as a Scenario block. The Scenario block may be connected toone or more message-based connections. In addition, a Scenario block mayinclude a specification of one or more valid and/or invalidinteractions. That is, the specification may define the messages thatare expected to be exchanged on the one or more message-basedconnections that have been associated with the Scenario block. A set ofmessages in a particular order may be referred to as a trace. TheScenario block may also include one or more constraints on the expectedmessages. When the model is executed, the verification engine 218, basedon information contained in the Scenario block, may determine whetherthe messages actually generated during execution are equivalent to theexpected messages and/or satisfy the one or more constraints. If not,the verification engine 218 may take one or more actions, such assuspending the execution of the model, stopping execution of the model,issuing an alert, outputting the non-conforming message or trace,generating a new scenario block whose specification corresponds to thenon-conforming message or trace, etc. The Scenario block may alsodisplay information concerning the actual messages generated duringexecution of the model.

FIG. 14 is a schematic illustration of a graphical model 1400 havingexecutable semantics. The model 1400 includes a plurality ofinterconnected components. Specifically, the model 1400 has two Inports1402, 1404, a Sensors component 1406, a Bus component 1408, a Controllercomponent 1410, an Actuators component 1412, and an Outport 1414. TheInports 1402, 1404 and the Outport 1414 may be time-based blocks, whilethe Sensors, Bus, Controller, and Actuators components 1406, 1408, 1410,1412 may be message-based blocks. The Bus component 1408 may beconnected to the Sensors component 1406 by two message-based connections1416, 1418. The Controller component 1410 may be connected to the Buscomponent 1408 by a message-based connection 1419. The Actuatorscomponent 1412 may be connected to the Controller component 1410 by fivemessage-based connections 1420-1424.

FIGS. 15A and 15B are partial views of a flow diagram illustratingexemplary processing that can be used in accordance with an embodimentof the invention.

The verification engine 218 may receive a request for one or moreScenario blocks to be added to a model, as indicated at block 1502.Suppose, for example, a user is interested in evaluating the manner inwhich the Bus component 1408 and the Controller component 1410 processmessages. The user may request a first Scenario block to evaluate themessages generated and received by the Bus component 1408, and a secondScenario block to evaluate the messages generated and received by theController component. The user may issue a request for a Scenario blockgraphically, textually or through a combination of textual and graphicalinputs to the high-level modeling environment. For example, a user mayselect a Scenario block from a library browser.

In response, the constructor 224 may create an instance of a Scenarioobject, and the model builder 210 may add a Scenario block to the modelcanvas displaying the model, as indicated at block 1504. Specifically,the verification engine 218 may add first and second Scenario blocks1426, 1428 to the model 1400. The verification engine 218 may alsoreceive a designation of one or more message-based components to beassociated with each Scenario block, as indicated at block 1506. Forexample, a user may associate the first Scenario block 1426 with themessages corresponding to message-based connections 1416, 1418, and1419. The user may also associate the second Scenario block 1428 withthe messages corresponding to message-based connections 1419 and1422-1424.

The verification engine 218 may receive information specifying aninteraction, as indicated at block 1508. That is, the verificationengine 218 may receive information concerning the messages expected tobe generated and sent during model execution. In an embodiment, aScenario block may include a plurality of GUI elements for receivinginformation specifying an interaction. For example, because it isassociated with message-based connections 1416, 1418, and 1419, thefirst Scenario block 1426 may include a Sensors box element 1430, a Busbox element 1432, and a Controller box element 1434. A line element,such as line elements 1436, 1438, and 1440 may extend from each boxelement 1430, 1432, and 1434, respectively. A user may specify one ormore expected messages by drawing arrow elements between line elements1436, 1438, and 1440. The specification may include the type of message,its payload, and its timing characteristics, among other information.For example, the user may specify the sending of an Altitude typemessage from the Sensors component 1406 to the Bus component, asindicated by arrow element 1442, and the sending of an Altitude typemessage from the Bus component 1408 to the Controller component 1410, asindicated by arrow element 1444.

The user may also specify one or more constraints for the expectedmessages. For example, the user may specify that the second altitudemessage 1444 is to be received by the Controller component 1410 within1.0 seconds of when the Sensors component sends the first altitudemessage 1142. The specification of this timing constraint may beperformed by the user at the first Scenario block 1426. For example, theuser may specify a time sent, T_(S), value of ‘timeNow’ for the sendingof the first altitude message 1442 by the Sensors component 1406 at thetail of the arrow element 1442 where it joins line element 1436. Theuser may also specify a time receive, T_(R), value of ‘timeNow<=1 sec.’for the receipt of the second altitude message 1444 by the Controllercomponent 1410 at the head of arrow element 1444 where it joins lineelement 1440. Alternative embodiments may allow constraints to beprogrammatically specified by system 100.

The user may specify that two anomaly messages are expected asrepresented by arrow elements 1446 and 1448, and that the second anomalymessage 1448 should be received by the Controller component 1434 within0.1 seconds of when the first anomaly message is sent by the Sensorscomponent 1406.

It should be understood that a determined order of the messages may bespecified, for example, by a user or programmatically. The determinedorder may be specified within the Message Scenario block, and may be asequential order.

A Scenario block may receive additional constraints besides or inaddition to constraints concerning the ordering and timing of messages.

The information specified in a Message Scenario block, such as thesource and destination components, message types, payloads, andconstraints, may be referred to as an interaction. Other techniquesbesides or in addition to the use of arrow and other GUI elements may beused to specify an interaction or one or more parts thereof, for exampleone or more textual inputs may be used.

The second Scenario block 1428 may include a Bus box element 1450, aController box element 1452, and an Actuators box element 1454, since itis associated with message-based connections 1419 and 1422-1424. A lineelement, such as line elements 1456, 1458, and 1460, may extend fromeach box element 1450, 1452, and 1454, respectively. Between lineelements 1456, 1458, and 1460, the user may draw arrow elementsrepresenting the messages expected to be sent by the Bus component 1408and received at the Controller component 1410, and the order of thosemessages. The user may specify a determined order, such as a sequentialorder, of message occurrence textually and/or graphically, for example,by drawing the arrow elements that represent those messages in avertically descending order. That is, the message represented by a firstarrow element is expected to occur before a second message representedby a second arrow element, if the first arrow element is drawn above thesecond arrow element in the Scenario block.

As shown in the second Scenario block 1428, a user may draw two arrowelements between lines 1456 and 1458 associated with the Bus andController components 1408, 1410. Specifically, the user may draw afirst arrow element 1462 representing an Altitude type message with apayload of ‘10,000’, and a second arrow element 1464 representing anAnomaly type message. Following this sequence of messages between theBus and Controller components 1408, 1410, the user may draw arrowelements representing expected messages between the Controller andActuators components 1410, 1412. Specifically, the user may draw a thirdarrow element 1466 representing a ‘DumpFuel’ type message, a fourtharrow element 1468 representing a ‘ReleaseStage’ type message, and afifth arrow element 1470 representing a ‘ReleaseTank’ type message.

The verification engine 218 may also receive one or more actions thatare to be performed if an actual message occurs during the execution ofthe model 1400 that is not equivalent to the specified interaction, orto one or more constraints specified in a Scenario block, as indicatedat block 1510. For example, a user may open a property page (not shown)associated with a Scenario block, and may specify a desired action,e.g., by selecting one or more radio buttons or checkboxes. Actions thatmay be specified may include stopping the execution of the model,pausing or suspending its execution, until released, e.g., by the user,logging an error, outputting the one or more actual messages, generatinga new Scenario block whose specification is the one or more actualmessages and using the new Scenario block in the model, and/orpresenting an alert. The particular action or actions may beuser-settable, for example, through a property page or dialog of theScenario block.

After the one or more Scenario blocks have been configured as desired,e.g., by the user or programmatically, the model 1400 may be executed,as indicated at block 1512. As part of the execution of the model 1400,the Sensors, Bus, and Controller components 1406, 1408, 1410 maygenerate and send one or more messages. The verification engine 218 maymonitor the sending and receiving of messages across the message-basedconnections that have been associated with the one or more Scenarioblocks, as indicated at block 1514. In addition, the verification engine218 may compare the actual messages that occur during execution of themodel 1400 with the interaction contained by the one or more Scenarioblocks, as indicated at block 1516 (FIG. 15B). The verification engine218 may determine whether an actual message occurs that is notequivalent to an expected message as specified by the interaction, asindicated at decision block 1518. If an actual message is notequivalent, the verification engine 218 may perform the specifiedaction, as indicated by No arrow 1520 leading to block 1522. Theverification engine 218 may also determine whether an actual messagefails to satisfy a constraint specified through a Scenario block, asindicated by decision block 1522. If an actual message does not satisfya constraint, the verification engine 218 may perform the specifiedaction, as indicated by No arrow 1524 leading to block 1526. It shouldbe understood that the same action may be performed. If the actualmessages occur according to the determined order, and satisfy any otherspecified constraints, the model 1400 may execute to completion, asindicated by Yes arrows 1528, 1530 leading to block 1532. The specifiedaction may include or may be allowing the model to continue execution.

It should be understood that other or different GUI elements may beutilized or supported by one or more of the verification blocks. Forexample, an additional GUI element may be provided for the Scenarioblocks through which a series of looping messages may be specified by auser.

In an embodiment, the high-level modeling environment 200 may includeone or more code generation modules for generating code from a model,such as C code, C++ code, Hardware Description Language (HDL) code, etc.The code generation module may generate code for one or moreverification blocks, such as the Scenario blocks. If the code for theScenario block detects an invalid trace, for example, it may generate anerror message that could be read by another code module, which in turnmay take some predetermined action, such as resetting the deployedsystems, or sending a signal to a processing unit.

The generated code, moreover, may be used in a deployed system, that maybe a real-world system that is physically separate from the dataprocessing system 100 on which the high-level modeling environment 200operates. Exemplary deployed systems include controllers, such as EngineControl Units (ECUs) used in cars and trucks, Anti-lock Braking Systems(ABS), aircraft flight control systems, etc.

Suitable code generation models include the Real Time Workshop codegenerator and the Simulink HDL Coder products from The MathWorks, Inc.

The foregoing description of embodiments is intended to provideillustration and description, but is not intended to be exhaustive or tolimit the invention to the precise form disclosed. Modifications andvariations are possible in light of the above teachings or may beacquired from a practice of the invention. For example, while a seriesof acts has been described above with respect to the flow diagrams, theorder of the acts may be modified in other implementations. Further,non-dependent acts may be performed in parallel. Also, the term “user”,as used herein, is intended to be broadly interpreted to include, forexample, a computer or data processing system (e.g., system 100) or auser of a computer or data processing system, unless otherwise stated.

Further, certain embodiments of the invention may be implemented aslogic that performs one or more functions. This logic may behardware-based, software-based, or a combination of hardware-based andsoftware-based. Some or all of the logic may be stored in one or moretangible non-transitory computer-readable storage media and may includecomputer-executable instructions that may be executed by a computer ordata processing system, such as system 100. The computer-executableinstructions may include instructions that implement one or moreembodiments of the invention. The tangible non-transitorycomputer-readable storage media may be volatile or non-volatile and mayinclude, for example, flash memories, dynamic memories, removable disks,and non-removable disks.

No element, act, or instruction used herein should be construed ascritical or essential to the invention unless explicitly described assuch. Also, as used herein, the article “a” is intended to include oneor more items. Where only one item is intended, the term “one” orsimilar language is used. Further, the phrase “based on” is intended tomean “based, at least in part, on” unless explicitly stated otherwise.

The foregoing description has been directed to specific embodiments ofthe present invention. It will be apparent, however, that othervariations and modifications may be made to the described embodiments,with the attainment of some or all of their advantages. For example, oneor more message-based blocks, such as a verification block, may beconfigured through a command line Application Programming Interface(API) that may be provided by the message-based object constructor orthe verification engine. Therefore, it is the object of the appendedclaims to cover all such variations and modifications as come within thetrue spirit and scope of the invention.

What is claimed is:
 1. A method comprising: accessing, from a memory, anexecutable graphical model having a plurality of graphical components,the plurality of graphical components exchanging messages duringexecution of the graphical model, the messages include payloads havingone or more data values that remain fixed while the messages travelbetween respective pairs of the graphical components, and persist for adetermined time interval during execution of the graphical model; andexecuting the graphical model by a processor coupled to the memory, theexecuting including: generating a given message by a first graphicalcomponent of the graphical model; receiving the given message at asecond graphical component of the graphical model, the second graphicalcomponent being a time-based graphical component or a state-basedgraphical component; and consuming, by the second graphical component ofthe graphical model, the given message, where the consuming the givenmessage includes processing at least one of the one or more data valuesof the given message, and is performed before an expiration of thedetermined time interval of the given message.
 2. The method of claim 1wherein the given message is received at a message queue associated withthe second graphical component, and the consuming the given messagefurther includes retrieving the given message from the message queue. 3.(canceled)
 4. The method of claim 1 wherein the graphical model executesover a plurality of time steps between a start time and an end time, andthe determined time interval of the given message is one or more timesteps between the start time and the end time.
 5. The method of claim 1further comprising: sending the given message to the second graphicalcomponent, wherein execution of the second graphical component istriggered upon the sending of the given message or upon the receiving ofthe given message.
 6. The method of claim 1 further comprising:providing the second graphical component with a message port; andspecifying a message-based connection between the first graphicalcomponent and the message port of the second graphical component,wherein the message-based connection is specified graphically. 7.(canceled)
 8. The method of claim 1 wherein execution of the firstgraphical component proceeds synchronously or asynchronously after thegiven message is generated.
 9. The method of claim 1 further comprising:sending the given message to the second graphical component; andreceiving at the first graphical component a reply to the given message,wherein execution of the first graphical component: pauses upon thesending of the given message to the second graphical component, andresumes upon the first graphical component receiving the reply to thegiven message.
 10. The method of claim 1 further comprising: sending thegiven message to the second graphical component, wherein execution ofthe first graphical component continues without pausing upon the sendingof the given message to the second graphical component. 11-14.(canceled)
 15. The method of claim 1 further comprising: generating codefrom at least a portion of the executable graphical model.
 16. Themethod of claim 15 wherein the code is source code.
 17. The method ofclaim 15 wherein the code is C code, C++ code, or Hardware DescriptionLanguage (HDL) code.
 18. The method of claim 15 further comprising:deploying the code to a physical system; and running the code by thephysical system. 19-20. (canceled)
 21. A method comprising: accessing,from a memory, an executable graphical model having a plurality ofgraphical components, the plurality of graphical components configuredto exchange messages during execution of the graphical model, themessages include payloads having one or more data values that remainfixed while the messages travel between respective pairs of thegraphical components, and persist for a determined time interval duringexecution of the graphical model; and generating code from at least aportion of the executable graphical model, where the code includesinstructions for generating a given message by a first entity, the firstentity corresponding to a first graphical component of the executablegraphical model; receiving the given message at a second entity, thesecond entity corresponding to a time-based graphical component or astate-based graphical component of the executable graphical model; andprocessing at least one of the one or more data values of the givenmessage by the second entity before an expiration of the determined timeinterval of the given message.
 22. The method of claim 21 furthercomprising: deploying the standalone executable code to a target device;and running the standalone executable code at the target device.
 23. Themethod of claim 21 wherein the code is source code.
 24. The method ofclaim 21 wherein the code is C code, C++ code, or Hardware DescriptionLanguage (HDL) code.
 25. The method of claim 21 wherein the code furtherincludes instructions for creating a message queue; and storing thegiven message at the message queue.
 26. One or more non-transitorycomputer-readable media comprising program instructions, the programinstructions when executed by one or more processors operable to:access, from a memory, an executable graphical model having a pluralityof graphical components, the plurality of graphical componentsexchanging messages during execution of the graphical model, themessages include payloads having one or more data values that remainfixed while the messages travel between respective pairs of thegraphical components, and persist for a determined time interval duringexecution of the graphical model; and execute the graphical model by theone or more processors, the executing including: generating a givenmessage by a first graphical component of the graphical model; receivingthe given message at a second graphical component of the graphicalmodel, the second graphical component being a time-based graphicalcomponent or a state-based graphical component; and consuming, by thesecond graphical component of the graphical model, the given message,where the consuming the given message includes processing at least oneof the one or more data values of the given message, and is performedbefore an expiration of the determined time interval of the givenmessage.
 27. The one or more non-transitory computer-readable media ofclaim 26 wherein the given message is received at a message queueassociated with the second graphical component, and the consuming thegiven message further includes retrieving the given message from themessage queue.
 28. The one or more non-transitory computer-readablemedia of claim 26 wherein execution of the first graphical componentproceeds synchronously or asynchronously after the given message isgenerated.
 29. The one or more non-transitory computer-readable media ofclaim 26 further comprising instructions to: send the given message tothe second graphical component; and receive at the first graphicalcomponent a reply to the given message, wherein execution of the firstgraphical component: pauses upon the sending of the given message to thesecond graphical component, and resumes upon the first graphicalcomponent receiving the reply to the given message.
 30. The one or morenon-transitory computer-readable media of claim 26 further comprisinginstructions to: send the given message to the second graphicalcomponent, wherein execution of the first graphical component continueswithout pausing upon the sending of the given message to the secondgraphical component.
 31. An apparatus comprising: a memory storing anexecutable graphical model having a plurality of graphical components,the plurality of graphical components exchanging messages duringexecution of the graphical model, the messages include payloads havingone or more data values that remain fixed while the messages travelbetween respective pairs of the graphical components, and persist for adetermined time interval during execution of the graphical model; and aprocessor coupled to the memory, the processor configured to execute thegraphical model, where the processor is further configured, duringexecution of the graphical model, to: generate a given message by afirst graphical component of the graphical model; receive the givenmessage at a second graphical component of the graphical model, thesecond graphical component being a time-based graphical component or astate-based graphical component; and consume, by the second graphicalcomponent of the graphical model, the given message, where the consumingthe given message includes processing at least one of the one or moredata values of the given message, and is performed before an expirationof the determined time interval of the given message.
 32. The apparatusof claim 31 wherein the given message is received at a message queueassociated with the second graphical component, and the consuming thegiven message further includes retrieving the given message from themessage queue.
 33. The apparatus of claim 31 wherein the processor isfurther configured to proceed with execution of the first graphicalcomponent synchronously or asynchronously after the given message isgenerated.
 34. The apparatus of claim 31 wherein the processor isfurther configured to: send the given message to the second graphicalcomponent; and receive at the first graphical component a reply to thegiven message, wherein execution of the first graphical component:pauses upon the sending of the given message to the second graphicalcomponent, and resumes upon the first graphical component receiving thereply to the given message.
 35. The apparatus of claim 31 wherein theprocessor is further configured to: send the given message to the secondgraphical component, wherein execution of the first graphical componentcontinues without pausing upon the sending of the given message to thesecond graphical component.
 36. One or more non-transitorycomputer-readable media comprising program instructions, the programinstructions when executed by one or more processors operable to:access, from a memory, an executable graphical model having a pluralityof graphical components, the plurality of graphical componentsconfigured to exchange messages during execution of the graphical model,the messages include payloads having one or more data values that remainfixed while the messages travel between respective pairs of thegraphical components, and persist for a determined time interval duringexecution of the graphical model; and generate, by a processor coupledto the memory, code from at least a portion of the executable graphicalmodel, where the code includes instructions for generating a givenmessage by a first entity, the first entity corresponding to a firstgraphical component of the executable graphical model; receiving thegiven message at a second entity, the second entity corresponding to atime-based graphical component or a state-based graphical component ofthe executable graphical model; and processing at least one of the oneor more data values of the given message by the second entity before anexpiration of the determined time interval of the given message.
 37. Theone or more non-transitory computer-readable media of claim 36 furthercomprising program instructions to: deploy the standalone executablecode to a target device; and run the standalone executable code at thetarget device.
 38. The one or more non-transitory computer-readablemedia of claim 36 wherein the code is source code.
 39. The one or morenon-transitory computer-readable media of claim 36 wherein the code is Ccode, C++ code, or Hardware Description Language (HDL) code.
 40. The oneor more non-transitory computer-readable media of claim 36 wherein thecode further includes instructions for creating a message queue; andstoring the given message at the message queue.
 41. An apparatuscomprising: a memory storing an executable graphical model having aplurality of graphical components, the plurality of graphical componentsconfigured to exchange messages during execution of the graphical model,the messages include payloads having one or more data values that remainfixed while the messages travel between respective pairs of thegraphical components, and persist for a determined time interval duringexecution of the graphical model; and a processor coupled to the memory,the processor configured to generate code from at least a portion of theexecutable graphical model, where the code includes instructions forgenerating a given message by a first entity, the first entitycorresponding to a first graphical component of the executable graphicalmodel; receiving the given message at a second entity, the second entitycorresponding to a time-based graphical component or a state-basedgraphical component of the executable graphical model; and processing atleast one of the one or more data values of the given message by thesecond entity before an expiration of the determined time interval ofthe given message.
 42. The apparatus of claim 41 wherein the processoris further configured to: deploy the standalone executable code to atarget device; and run the standalone executable code at the targetdevice.
 43. The apparatus of claim 41 wherein the code is source code.44. The apparatus of claim 41 wherein the code is C code, C++ code, orHardware Description Language (HDL) code.
 45. The apparatus of claim 41wherein the code further includes instructions for creating a messagequeue; and storing the given message at the message queue.